Conversation
|
@Philip-Carneiro-KX This is not a real security issue. |
Security Vulnerability Analysis: Regex Denial of Service (ReDoS)Yes, this is a legitimate security vulnerability known as ReDoS (Regex Denial of Service). Here's why: 1. Problematic Regex Pattern\/[\s\S]*?\\
2. Backtracking VulnerabilityWhen the ending
3. Why This is a Security Risk
4. Real-World Impact// Example attack payload
const maliciousInput = `/${'a'.repeat(100_000_000)}`; // 100M characters
5. How to Fix ItOption 1: Use a Parser Instead Option 2: Safeguard the Regex
\/[\s\S]*?\\/Still risky. Prefer parser-based solutions. Key TakeawayWhile your regex isn’t catastrophically exponential (like nested quantifiers), its linear worst-case behavior on large inputs makes it vulnerable to DoS attacks. Always validate input size and prefer non-regex solutions for complex parsing. |
|
|
@Philip-Carneiro-KX I meant in the real world use cases, before adding 100+ million chars in a file, the Monaca editor in vscode itself and vscode will probably crash. This is no a server side software, we are dealing with a language server extension here, it is running on vscode extension host sandbox, and ultimately on nodejs so we should use regexes when dealing with source code. We can modify the regex instead of writing and maintaining a parser just for this. |




Changes introduced by this PR